<template>
    <view class="content">
        <!-- <view class="top">
            <view class="padding-lr-sm">
                <u-search placeholder="搜索内容" v-model="keyword" :show-action="false" height="70" @search="doSearch"></u-search>
            </view>
            <timeSearch @doSearch="doSearch" />
        </view> -->
        
        <view class="box" v-for="(item, index) in list" :key="index" 
            @click="$gTo(`/pages/house-plan/check-details?id=${item.id}&plan_id=${id}&category=${item.category}&member=${item.member}&pdate=${item.pdate}`)">
            <view class="u-flex">
                <view class="text-lg text-bold u-flex-1">{{item.category}}</view>
                <!-- order_status 0-未完  1-已完 -->
                <view class="drug-state1" v-if="item.order_status == 1">已完成</view>
                <view class="drug-state2" v-if="item.order_status == 0">未完成</view>
            </view>
            <view class="down">
                <view class="text-df text-gray">
                    <view class="u-p-t-5">创建人：{{item.creater}}</view>
                    <view class="u-p-t-5">计划时间：{{item.pdate}}</view>
                    <view class="u-p-t-5" v-if="item.finish_time">盘点时间：{{item.finish_time.split(' ')[0]}}</view>
                </view>
                <!-- <view class="drug-btn" v-if="item.order_status == 0">去盘点</view> -->
            </view>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                id: '',
                list: [],
                keyword: '',
                startTime: '',
                endTime: '',
                
            };
        },
        onLoad(option) {
            this.id = option.id
        },
        onShow() {
            this.getList()
        },
        methods: {
            // doSearch(data) {
            //     if (data) {
            //         this.startTime = data.startTime
            //         this.endTime = data.endTime
            //     }
            //     this.getList()
            // },
            
            // 获取盘点子计划
            getList() {
            	this.$ajax('inventorys/sub_plan_list', {
                    userToken: this.$getSync('userToken'),
                    id: this.id,
                }).then(ret => {
            		if (ret.status == 0) {
                        this.list = ret.data
                        // this.list.forEach(cur => {
                        //     this.$set(cur, 'star', cur.pbegin.split(' ')[0])
                        //     this.$set(cur, 'end', cur.pend.split(' ')[0])
                        // })
            		} else {
            			this.$toast(ret.message);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    
    
    page{
        background-color: #f5f5f5 !important;
    }
    .content{
        padding-bottom: 150rpx;
    }
    .top{
        background-color: #fff;
    }
    
    .box{
        background-color: #fff;
        border-radius: 15rpx;
        padding: 30rpx 25rpx;
        margin: 25rpx 25rpx 0;
        word-break: break-all;
        white-space: pre-line;
    }
    
    .drug-state1{
        font-size: 24rpx;
        color: #0075ff;
        padding: 9rpx 12rpx;
        background-color: #ebf4fe;
        border-radius: 8rpx;
        margin-left: 20rpx;
    }
    .drug-state2{
        font-size: 24rpx;
        color: #00c28f;
        padding: 9rpx 12rpx;
        background-color: #e9fbf6;
        border-radius: 8rpx;
        margin-left: 20rpx;
    }
    .down{
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
    }
    .drug-btn{
        color: #fff;
        padding: 10rpx 20rpx;
        background-color: #8392a5;
        border-radius: 8rpx;
        margin-left: 20rpx;
    }
    

</style>
